package ui.panels.distributionPanels;

import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent;

import javax.swing.JFrame;

import ui.flowManager.FlowManagerImpl;

/**
 * @author vladimir && alon
 *	Little JFrame for distribution panel
 *	When open this JFrame the, the previous JFrame (the primary GUI) is disabled
 */
public class DistributionFrame extends JFrame{

	private String distribution;
	
	/**
	 * CTOR
	 */
	public	DistributionFrame(String distribution)
	{
		super();
		
		this.distribution = distribution;
        setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
        setSize(300,275);
        setResizable(false);
        //This will center the JFrame in the middle of the screen
        setLocationRelativeTo(null);
        setVisible(true);
        //disable the the primary GUI
        FlowManagerImpl.getInstance().setEnable(false);
        
        //set listener to close
        addWindowListener(new WindowEventHandler());
	}
	
	/**
	 * @author vladimir && alon
	 *	When the Frame is closed enable the prime GUI
	 */
	private class WindowEventHandler extends WindowAdapter {
		  public void windowClosing(WindowEvent evt) { 
		    //set enable the primary GUI
			 FlowManagerImpl.getInstance().setEnable(true);
		  }
	}

	/*** @return distribution */
	public String getDistribution() {
		return distribution;
	}
	
}
